﻿/**
 * @des 新建会议
 */
function newMeeting() {
	_global.win = buildWindow("新建会议",
								100,
								50,
								650,
								500,
								"meetingContent",
								true);
}

btnNew.addEventListener("click", newMeeting);


/**
 * @des 参加已有会议
 */
function joinMeeting() {
	var id:Number = meetingList.selectedItem.id;
	
	if (typeof(id) == "number") {
		currentInfo.data.meetingId = id;
		currentInfo.data.meetingMode = meetingList.selectedItem.meetingMode;
		currentInfo.data.meetingName = meetingList.selectedItem.meetingName;
		currentInfo.data.meetingTheme = meetingList.selectedItem.meetingTheme;
		currentInfo.data.memberList = meetingList.selectedItem.memberList;
		currentInfo.data.createUser = meetingList.selectedItem.createUser;
		currentInfo.data.createTime = meetingList.selectedItem.createTime;

		currentInfo.data.prolocutor = "";
		
		/**
		 * @des 获取成员ID与成员名称的对照表，即服务器端的成员列表
		 */
		var so:SharedObject = SharedObject.getRemote("meetingList", nc.uri, true);
		so.connect(nc);
		
		/**
		 * @des 同步服务器端会议列表
		 */
		so.onSync = function() {
			for (x in so.data) {
				if (so.data[x].id == id) {
					currentInfo.data.idAndName = so.data[x].memberList;
					trace(so.data[x].memberList);
					currentInfo.data.allowPrivateChat = so.data[x].allowPrivateChat;
					currentInfo.data.showAll = so.data[x].showAll;
					nextFrame();
					
					// 更新服务器端当前用户所参加的会议
					nc.call("updateCurrentMeeting",
							null,
							id);
				}
			}
		};
	} else {
		alert("系统提示", "请选择要参加的会议！", 1);
	}
}

btnJoin.addEventListener("click", joinMeeting);


/**
 * @des 删除会议
 */
function deleteMeeting() {
	var id:Number = meetingList.selectedItem.id;
	
	if (typeof(id) == "number") {
		nc.call("deleteMeeting", null, id);
	}
}

btnDel.addEventListener("click", deleteMeeting);
